import fs from 'fs'
import parser from '@babel/parser'
import _traverse from '@babel/traverse'
const traverse = _traverse.default || _traverse
import t from '@babel/types'
import { generate } from '@babel/generator'

const code = fs.readFileSync('./input.js', { encoding: 'utf-8' })
const ast = parser.parse(code, {
  sourceType: 'module'
})

// 对 AST 进行操作

const outputCode = generate(ast).code
fs.writeFileSync('./output.js', outputCode)
console.log('代码转换完成，输出文件为 output.js')
